from rangetest import rangetest
# Test functions, positional and keyword


@rangetest(age=(0, 120))  # persinfo = rangetest(...)(persinfo)
def persinfo(name, age):
    print('%s is %s years old' % (name, age))


@rangetest(M=(1, 12), D=(1, 31), Y=(0, 2013))
def birthday(M, D, Y):
    print('birthday = {0}/{1}/{2}'.format(M, D, Y))


persinfo('Bob', 40)
persinfo(age=40, name='Bob')

birthday(3, D=1, Y=1963)
#persinfo('Bob', 150)
#persinfo(age=150, name='Bob')
#birthday(5, D=40, Y=1963)
# Test methods, positional and keyword
# class Person:
#     def __init__(self, name, job, pay):
#         self.job = job
#         self.pay = pay
# 	# giveRaise = rangetest(...)(giveRaise)
#     @rangetest(percent=(0.0, 1.0)) # percent passed by name or position
#     def giveRaise(self, percent):
#         self.pay = int(self.pay * (1 + percent))
# bob = Person('Bob Smith', 'dev', 100000)
# sue = Person('Sue Jones', 'dev', 100000)
# bob.giveRaise(.10)
# sue.giveRaise(percent=.20)
# print(bob.pay, sue.pay)
# bob.giveRaise(1.10)
# bob.giveRaise(percent=1.20)
# Test omitted defaults: skipped


@rangetest(a=(1, 10), b=(1, 10), c=(1, 10), d=(1, 10))
def omitargs(a, b=7, c=8, d=9):
    print(a, b, c, d)


omitargs(1, d=8, c=7, b=6, e=10)
# omitargs(1, 2, 3, 4)
# omitargs(1, 2, 3)
# omitargs(1, 2, 3, d=4)
# omitargs(1, d=4)
# omitargs(d=4, a=1)
# omitargs(1, b=2, d=4)
# omitargs(d=8, c=7, a=1)
# omitargs(1, 2, 3, 11) # Bad d
# omitargs(1, 2, 11) # Bad c
# omitargs(1, 2, 3, d=11) # Bad d
# omitargs(11, d=4) # Bad a
# omitargs(d=4, a=11) # Bad a
# omitargs(1, b=11, d=4) # Bad b
# omitargs(d=8, c=7, a=11) # Bad a
